using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MobileWebsiteGenerator.Entities;

namespace MobileWebsiteGenerator.Mapping
{
	public class WebthemeRelMap : EntityTypeConfiguration<WebthemeRel>
	{
		public WebthemeRelMap()
		{
			// Primary Key
			this.HasKey(t => t.Web_theme_id);

			// Properties
			this.Property(t => t.Web_theme_id)
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
				
			// Table & Column Mappings
			this.ToTable("WebthemeRel");
			this.Property(t => t.Web_theme_id).HasColumnName("Web_theme_id");
			this.Property(t => t.Web_id).HasColumnName("Web_id");
			this.Property(t => t.Theme_id).HasColumnName("Theme_id");

			// Relationships
			this.HasRequired(t => t.ThemeDetail)
				.WithMany(t => t.WebthemeRels)
				.HasForeignKey(d => d.Theme_id);
				
			this.HasRequired(t => t.Website)
				.WithMany(t => t.WebthemeRels)
				.HasForeignKey(d => d.Web_id);
				
		}
	}
}

